using UnityEngine;

namespace Coffee.UIExtensions
{
    // [Assembly-CSharp.dll].Coffee.UIExtensions.UIHsvModifier
    public class UIHsvModifier : UIEffectBase
    {
        // Fields
        public const string shaderName = "UI/Hidden/UI-Effect-HSV";
        private static readonly Coffee.UIExtensions.ParameterTexture _ptex;
        private UnityEngine.Color m_TargetColor;
        private float m_Range;
        private float m_Hue;
        private float m_Saturation;
        private float m_Value;
        
        // Properties
        public UnityEngine.Color targetColor { get; set; }
        public float range { get; set; }
        public float saturation { get; set; }
        public float value { get; set; }
        public float hue { get; set; }
        public override Coffee.UIExtensions.ParameterTexture ptex { get; }
        
        // Methods
        public UnityEngine.Color get_targetColor()
        {
            return new UnityEngine.Color() {r = this.m_TargetColor};
        }
        public void set_targetColor(UnityEngine.Color value)
        {
            UnityEngine.Color val_5 = this.m_TargetColor;
            val_5 = val_5 - value.r;
            float val_1 = S5 - value.g;
            val_5 = val_5 * val_5;
            val_1 = val_1 * val_1;
            val_5 = val_5 + val_1;
            float val_2 = S6 - value.b;
            val_2 = val_2 * val_2;
            val_5 = val_2 + val_5;
            val_5 = ((S7 - value.a) * (S7 - value.a)) + val_5;
            if(val_5 < 0)
            {
                    return;
            }
            
            this.m_TargetColor = value;
            mem[1152921504930430456] = value.g;
            mem[1152921504930430460] = value.b;
            mem[1152921504930430464] = value.a;
            goto typeof(Coffee.UIExtensions.UIHsvModifier).__il2cppRuntimeField_2D8;
        }
        public float get_range()
        {
            return (float)this.m_Range;
        }
        public void set_range(float value)
        {
            double val_10;
            float val_1 = (value >= 0) ? 1f : 0f;
            float val_10 = System.Math.Abs(this.m_Range);
            float val_11 = System.Math.Abs(val_1);
            float val_12 = 1E-06f;
            val_12 = ((val_10 > val_11) ? (val_10) : (val_11)) * val_12;
            float val_13 = 8f;
            val_13 = mem[536889545] * val_13;
            float val_4 = (val_12 > val_13) ? (val_12) : (val_13);
            if((val_1 ?? this.m_Range) < 0)
            {
                    return;
            }
            
            this.m_Range = val_1;
            val_10 = ???;
            goto typeof(Coffee.UIExtensions.UIHsvModifier).__il2cppRuntimeField_2D8;
        }
        public float get_saturation()
        {
            return (float)this.m_Saturation;
        }
        public void set_saturation(float value)
        {
            double val_10;
            float val_1 = (value >= 0) ? 0.5f : -0.5f;
            float val_10 = System.Math.Abs(this.m_Saturation);
            float val_11 = System.Math.Abs(val_1);
            float val_12 = 1E-06f;
            val_12 = ((val_10 > val_11) ? (val_10) : (val_11)) * val_12;
            float val_13 = 8f;
            val_13 = mem[536889545] * val_13;
            float val_4 = (val_12 > val_13) ? (val_12) : (val_13);
            if((val_1 ?? this.m_Saturation) < 0)
            {
                    return;
            }
            
            this.m_Saturation = val_1;
            val_10 = ???;
            goto typeof(Coffee.UIExtensions.UIHsvModifier).__il2cppRuntimeField_2D8;
        }
        public float get_value()
        {
            return (float)this.m_Value;
        }
        public void set_value(float value)
        {
            double val_10;
            float val_1 = (value >= 0) ? 0.5f : -0.5f;
            float val_10 = System.Math.Abs(this.m_Value);
            float val_11 = System.Math.Abs(val_1);
            float val_12 = 1E-06f;
            val_12 = ((val_10 > val_11) ? (val_10) : (val_11)) * val_12;
            float val_13 = 8f;
            val_13 = mem[536889545] * val_13;
            float val_4 = (val_12 > val_13) ? (val_12) : (val_13);
            if((val_1 ?? this.m_Value) < 0)
            {
                    return;
            }
            
            this.m_Value = val_1;
            val_10 = ???;
            goto typeof(Coffee.UIExtensions.UIHsvModifier).__il2cppRuntimeField_2D8;
        }
        public float get_hue()
        {
            return (float)this.m_Hue;
        }
        public void set_hue(float value)
        {
            double val_10;
            float val_1 = (value >= 0) ? 0.5f : -0.5f;
            float val_10 = System.Math.Abs(this.m_Hue);
            float val_11 = System.Math.Abs(val_1);
            float val_12 = 1E-06f;
            val_12 = ((val_10 > val_11) ? (val_10) : (val_11)) * val_12;
            float val_13 = 8f;
            val_13 = mem[536889545] * val_13;
            float val_4 = (val_12 > val_13) ? (val_12) : (val_13);
            if((val_1 ?? this.m_Hue) < 0)
            {
                    return;
            }
            
            this.m_Hue = val_1;
            val_10 = ???;
            goto typeof(Coffee.UIExtensions.UIHsvModifier).__il2cppRuntimeField_2D8;
        }
        public override Coffee.UIExtensions.ParameterTexture get_ptex()
        {
            if(mem[536895053] != 0)
            {
                    return (Coffee.UIExtensions.ParameterTexture)mem[536895013];
            }
            
            536894829 = 536894829;
            return (Coffee.UIExtensions.ParameterTexture)mem[536895013];
        }
        public override void ModifyMesh(UnityEngine.UI.VertexHelper vh)
        {
            if(this.isActiveAndEnabled == false)
            {
                    return;
            }
            
            float val_2 = this.GetNormalizedIndex(target:  this);
            int val_3 = vh.currentVertCount;
            if(val_3 < 1)
            {
                    return;
            }
            
            this = val_3;
            var val_5 = 0;
            do
            {
                vh.PopulateUIVertex(vertex:  new UnityEngine.UIVertex() {position = new UnityEngine.Vector3() {x = 0f, y = 0f, z = 0f}, normal = new UnityEngine.Vector3() {x = 0f, y = 0f, z = 0f}, tangent = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, color = new UnityEngine.Color32(), uv0 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv1 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv2 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}, uv3 = new UnityEngine.Vector4() {x = 0f, y = 0f, z = 0f, w = 0f}}, i:  0);
                float val_4 = Packer.ToFloat(x:  0f, y:  0f);
                vh.SetUIVertex(vertex:  new UnityEngine.UIVertex() {position = new UnityEngine.Vector3(), normal = new UnityEngine.Vector3(), tangent = new UnityEngine.Vector4(), color = new UnityEngine.Color32(), uv0 = new UnityEngine.Vector4(), uv1 = new UnityEngine.Vector4(), uv2 = new UnityEngine.Vector4(), uv3 = new UnityEngine.Vector4()}, i:  0);
                val_5 = val_5 + 1;
            }
            while(this != val_5);
        
        }
        protected override void SetDirty()
        {
            UnityEngine.Color.RGBToHSV(rgbColor:  new UnityEngine.Color() {r = this.m_TargetColor}, H:  null, S:  null, V:  null);
            this.RegisterMaterial(mat:  this.targetGraphic);
            this.SetData(target:  this, channelId:  0, value:  0f);
            this.SetData(target:  this, channelId:  1, value:  0f);
            this.SetData(target:  this, channelId:  2, value:  0f);
            this.SetData(target:  this, channelId:  3, value:  this.m_Range);
            float val_2 = this.m_Hue;
            val_2 = val_2 + 0.5f;
            this.SetData(target:  this, channelId:  4, value:  val_2);
            float val_3 = this.m_Saturation;
            val_3 = val_3 + 0.5f;
            this.SetData(target:  this, channelId:  5, value:  val_3);
            float val_4 = this.m_Value;
            val_4 = val_4 + 0.5f;
            this.SetData(target:  this, channelId:  6, value:  val_4);
        }
        public UIHsvModifier()
        {
            this.m_Range = 0.1f;
            this.m_TargetColor = ;
            if(mem[536895019] != 0)
            {
                    return;
            }
        
        }
        private static UIHsvModifier()
        {
            Coffee.UIExtensions.ParameterTexture val_1 = 536890543;
            val_1 = new Coffee.UIExtensions.ParameterTexture(channels:  7, instanceLimit:  128, propertyName:  -1610600767);
            mem2[0] = val_1;
            throw new NullReferenceException();
        }
    
    }

}
